#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->pushButton, &QPushButton::clicked, this, &Widget::handlerClicked);
}

void Widget::handlerClicked()
{
//    // 当点击pushButton按钮时就将按钮中的hello world变成hello qt
//    ui->pushButton->setText("hello qt");

    // 当点击pushButton按钮时如果内容是hello world就将按钮中的hello world变成hello qt
    // 如果不是就变成hello world
    if(ui->pushButton->text() == "hello world") {
        ui->pushButton->setText("hello qt");
    } else {
        ui->pushButton->setText("hello world");
    }

}

Widget::~Widget()
{
    delete ui;
}

